#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;
const int N = 1e6 + 10;

int br[N], bl[N], gnum, bsize, gid[N];
ll sum[N], a[N];
void init_b(int n)
{
  bsize = sqrt(n) + 1;
  for (int i = 1; i <= n; i += bsize)
  {
    gnum += 1;
    bl[gnum] = i;
    br[gnum] = min(n, i + bsize - 1);
    for (int j = bl[gnum]; j <= br[gnum]; j++)
      gid[i] = gnum;
  }
  return;
}
ll get_sum(int l, int r)
{
  ll res = 0;
  for (int i = l; i <= r; i++)
    res += a[i];
  return res;
}
int main()
{
  ios::sync_with_stdio(0), cin.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++)
  {
    cin >> a[i];
    sum[gid[i]] += a[i];
  }
  while (q--)
  {
    int op, l, r, k;
    cin >> op;
    if (op == 1)
    {
      cin >> l >> r >> k;
      for (int i = l; i <= r; i++)
      {
        a[i] += k;
        sum[gid[i]] += k;
      }
    }
    else if (op == 2)
    {
      cin >> l >> r;
      if (gid[l] == gid[r])
        cout << get_sum(l, r) << '\n';
      else
      {
        ll res = 0;
        res += get_sum(l, br[gid[l]]);
        res += get_sum(bl[gid[r]], r);
        for (int i = gid[l] + 1; i < gid[r]; i++)
          res += sum[i];
        cout << res << '\n';
      }
    }
  }
  return 0;
}
